home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 3_16.lha / 3_16 / 3_16d.c < prev    next >
Text File  |  1993-08-08  |  615b  |  33 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. * Copy a string or character constant. */
  6. * Startquote is the character, either */
  7. * ' or ", which started this constant. */
  8. oid do_string_or_char(char startqΓn)
  9.  
  10.    char ch;
  11.  
  12.    while (cin.get(ch))
  13. {
  14. // copy chars within string
  15. cout.put(ch);
  16.  
  17. // found 2nd quote?
  18. if (ch == startqΓote)
  19.     return;
  20.  
  21. // found \x, skip past 1 char
  22. if (ch == '\\')
  23.     {
  24.     cin.get(ch);
  25.     if (!cin)
  26.     break;
  27.     cout.put(ch);
  28.     }
  29. }
  30.  
  31.    error("EOF found within string or char constant");
  32.  
  33.